﻿using Miao;
using RimWorld;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using Verse;
namespace Miao
{
    public class StorytellerCompProperties_OnOffCyclePoint : StorytellerCompProperties
    {
        public float onDays;

        public float offDays;

        public float onDaysNoTreeConnectors;

        public float offDaysNoTreeConnectors;

        public float minSpacingDays;

        public FloatRange numIncidentsRange = FloatRange.Zero;

        public SimpleCurve acceptFractionByDaysPassedCurve;
        /// <summary>
        /// 接受每个威胁点曲线的百分比因子
        /// </summary>
        public SimpleCurve acceptPercentFactorPerThreatPointsCurve;
        /// <summary>
        /// 接受百分比因素每进度得分曲线
        /// </summary>
        public SimpleCurve acceptPercentFactorPerProgressScoreCurve;

        public IncidentDef incident;

        private IncidentCategoryDef category;

        public float forceRaidEnemyBeforeDaysPassed;
        /// <summary>
        /// 点数百分比
        /// </summary>
        public float PointPercentage;

        public IncidentCategoryDef IncidentCategory
        {
            get
            {
                if (incident != null)
                {
                    return incident.category;
                }
                return category;
            }
        }

        public StorytellerCompProperties_OnOffCyclePoint()
        {
            compClass = typeof(StorytellerComp_OnOffCycle_Point);
        }

        public override IEnumerable<string> ConfigErrors(StorytellerDef parentDef)
        {
            if (incident != null && category != null)
            {
                yield return "incident and category should not both be defined";
            }
            if (onDays <= 0f)
            {
                yield return "onDays must be above zero";
            }
            if (numIncidentsRange.TrueMax <= 0f)
            {
                yield return "numIncidentRange not configured";
            }
            if (minSpacingDays * numIncidentsRange.TrueMax > onDays * 0.9f)
            {
                yield return "minSpacingDays too high compared to max number of incidents.";
            }
        }
    }
}